package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.player.UserChildSite;
import com.yanqu.road.pb.child.ChildProto;

import java.util.List;

public class ChildPb {

    public static ChildProto.ChildSiteTempMsg.Builder parseChildSiteTempMsg(UserChildSite childSite) {
        if(null == childSite){
            return null;
        }
        ChildProto.ChildSiteTempMsg.Builder msg = ChildProto.ChildSiteTempMsg.newBuilder();

        msg.setChildType(childSite.getChildType());
        msg.setName2(childSite.getChildName2());
        msg.setSiteIndex(childSite.getSiteIndex());
        msg.setTrainTimes(childSite.getTrainTimes());
        msg.setTrainCoolTime(childSite.getLastRestoreTime());
        msg.setChildUid(childSite.getChildUid());
        msg.setChildTalent(childSite.getChildTalent());
        msg.setOccupation(childSite.getChildOccupation());
        msg.setSex(childSite.getChildSex());
        msg.setName(childSite.getChildName());
        msg.setHeadIcon(childSite.getChildHeadIcon());
        msg.setCurrentGrowth(childSite.getCurrentGrowth());
        msg.setMotherId(childSite.getMotherBeautyId());
        msg.setTrainType(childSite.getTrainType());
        msg.setTrainCostSilver(childSite.getTrainCostSilver().toString());
        msg.setGrowAddEarnSpeed(childSite.getGrowAddEarnSpeed().toString());
        msg.setGrowAddEarnSpeed2(childSite.getGrowAddEarnSpeed2().toString());
        msg.setOpenComprehend(childSite.isComprehend());
        return msg;
    }

    public static ChildProto.ChildSiteListMsg.Builder parseChildSiteListMsg(List<UserChildSite> userChildSiteList){
        ChildProto.ChildSiteListMsg.Builder listMsg = ChildProto.ChildSiteListMsg.newBuilder();
        if(null != userChildSiteList) {
            for (UserChildSite child : userChildSiteList) {
                ChildProto.ChildSiteTempMsg.Builder msg = parseChildSiteTempMsg(child);
                if (null != msg) {
                    listMsg.addChildSiteList(msg);
                }
            }
        }
        return listMsg;
    }
}
